#define __USE_FILE_OFFSET64
#include <stddef.h>
#include <stdlib.h>
#include <stdio.h>
// #include <stdbool.h> // C23 not need
#include <sys/types.h>
#include <unistd.h>
#include <stdint.h>
#include <string.h>
#include <endian.h>
#include <byteswap.h>
#include <fcntl.h>
#include <time.h>
#include <sys/mman.h>
#include <sys/wait.h>
#include <libintl.h>

#define _(string) gettext(string)
#define speak(a) do {           \
        if (opt.logLevel != 0)  \
                printf(a);      \
} while (0)

typedef struct {
        bool color;
        bool help;
        bool random;
        bool force;
        bool test;
        bool seeded;
        bool started;
        bool sized;
        bool creat;
        char logLevel;
        FILE *fp;
        size_t start;
        size_t size;
        size_t end;
        uint64_t seed;
} option;
extern option opt;
#ifndef _GUI
void get_opt(int ac, char **av);
#endif // !_GUI

extern bool _true, _false;
int task(void *mult);
char *exe_file_path(char *name);

extern off_t *break_point;
extern size_t *head;
void write_random(void);
void write_num(void);
void test_num(void);
void test_seed(void);

void error_s(char *say);
void error_se(char *say);
void opt_err(void);
void perr_e(char *say);
void *malloc_se(size_t s);

#ifndef _GUI
void get_help(void);
#endif // _GUI

void loop_progress(void);

void fbinit(off_t start, bool read);
void fbread(void *bin, size_t size);
void fbwrite(void *bin, size_t size);
void fbflush(void);

extern pid_t main_pid;

#ifdef _GUI
#include "gui.h"
// main.c
extern struct break_collect *break_log_write;
// error.c
bool thrd_se(thrd_t *tid, int(*func)(void *), void *ptr);
#endif // _GUI
